package smartvillage.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import smartvillage.pojo.Admin;

@Mapper
public interface AdminMapper {
    //通过账户名查找管理员信息
    @Select("select * from smartvillage.admin_tb where username = #{username}")
    Admin getAdminByUsername(String username);

    //通过id查找管理员信息
    @Select("select * from smartvillage.admin_tb where id = #{id}")
    Admin getAdminById(Integer id);

    //修改管理员信息
    @Update("update smartvillage.admin_tb set username = #{username}, password = #{password}, " +
            "headPortrait = #{headPortrait}, nickname = #{nickname} where id = #{id}")
    void updateAdmin(Admin admin);

    //添加管理员信息
    @Insert("insert into smartvillage.admin_tb values (null, #{username}, #{password}, #{headPortrait}, #{nickname})")
    void addAdmin(Admin admin);
}
